package com.dragon.modules.yuegou.enums.code;

import com.dragon.common.constant.enums.IBusinessCode;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 会员业务状态码
 * 
 * @author 刘武
 *
 */
public enum CompanyCode implements IBusinessCode {

	/**
	 * 状态码说明
	 */
	TODO(18000, "提示消息"),
	EXCEL_DATA_NULL(18001,"批量导入企业员工未检测到有效数据行"),
	DUPLICATE_MOBILE_NUMBER_ERROR(18002,"批量导入企业员工存在手机号重复行");

	private final Integer code;

	private final String message;

	private CompanyCode(Integer code, String message) {
		this.code = code;
		this.message = message;
	}

	public Integer getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	/**
	 * 把code转化为ResponseCode枚举
	 * 
	 * @param code 代码
	 * @return
	 */
	public static CompanyCode from(Integer code) {
		if (code == null) {
			return null;
		}
		return CODE_MAP.get(code);
	}

	/**
	 * Code Map for ResponseCode
	 */
	private static final Map<Integer, CompanyCode> CODE_MAP = Stream.of(CompanyCode.values())
			.collect(Collectors.toMap(CompanyCode::getCode, e -> e));
	
}
